<?php

namespace IMooc;

/**
 * 事件生成器
 */
abstract class EventGenerator
{
    private array $observers = [];

    function addObserver(Observer $observer): void
    {
        $this->observers[] = $observer;
    }

    function notify(): void
    {
        foreach ($this->observers as $observer) {
            $observer->update();
        }
    }
}